

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="ShanCe">
  <meta name="keywords" content="">
  
    <meta name="description" content="场景一：重置root密码原理： mysql提供了特殊启动方式，跳过权限表验证，启动后，登录不需要提供密码。登陆后，即可修改密码，刷新权限，重启mysql即可 停止正在运行的mysql12# root 权限service mysqld stop 以–skip-grant-tables 选项启动服务，跳过权限表验证 方法一：指定运行选项，只在本次启动生效12.&#x2F;bin&#x2F;mysqld_safe --sk">
<meta property="og:type" content="article">
<meta property="og:title" content="Mysql忘记root密码解决方案">
<meta property="og:url" content="https://sweetshance.github.io/2024/04/23/mysql/Mysql%E5%BF%98%E8%AE%B0root%E5%AF%86%E7%A0%81%E8%A7%A3%E5%86%B3%E6%96%B9%E6%A1%88/index.html">
<meta property="og:site_name" content="ShanCe的博客">
<meta property="og:description" content="场景一：重置root密码原理： mysql提供了特殊启动方式，跳过权限表验证，启动后，登录不需要提供密码。登陆后，即可修改密码，刷新权限，重启mysql即可 停止正在运行的mysql12# root 权限service mysqld stop 以–skip-grant-tables 选项启动服务，跳过权限表验证 方法一：指定运行选项，只在本次启动生效12.&#x2F;bin&#x2F;mysqld_safe --sk">
<meta property="og:locale" content="zh_CN">
<meta property="article:published_time" content="2024-04-23T03:13:04.000Z">
<meta property="article:modified_time" content="2024-04-23T03:22:52.584Z">
<meta property="article:author" content="ShanCe">
<meta property="article:tag" content="mysql">
<meta name="twitter:card" content="summary_large_image">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>Mysql忘记root密码解决方案 - ShanCe的博客</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"sweetshance.github.io","root":"/","version":"1.9.4","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 5.4.2"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>ShanCe</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                <span>首页</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                <span>归档</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                <span>分类</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                <span>标签</span>
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                <span>关于</span>
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              <i class="iconfont icon-search"></i>
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">
              <i class="iconfont icon-dark" id="color-toggle-icon"></i>
            </a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/default.png') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="Mysql忘记root密码解决方案"></span>
          
        </div>

        
          
  <div class="mt-3">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-author" aria-hidden="true"></i>
        ShanCe
      </span>
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2024-04-23 11:13" pubdate>
          2024年4月23日 上午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          3.1k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          26 分钟
        
      </span>
    

    
    
      
        <span id="busuanzi_container_page_pv" style="display: none">
          <i class="iconfont icon-eye" aria-hidden="true"></i>
          <span id="busuanzi_value_page_pv"></span> 次
        </span>
        
      
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">Mysql忘记root密码解决方案</h1>
            
            
              <div class="markdown-body">
                
                <h3 id="场景一：重置root密码"><a href="#场景一：重置root密码" class="headerlink" title="场景一：重置root密码"></a>场景一：重置root密码</h3><p>原理： mysql提供了特殊启动方式，跳过权限表验证，启动后，登录不需要提供密码。登陆后，即可修改密码，刷新权限，重启mysql即可</p>
<h4 id="停止正在运行的mysql"><a href="#停止正在运行的mysql" class="headerlink" title="停止正在运行的mysql"></a>停止正在运行的mysql</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># root 权限</span><br>service mysqld stop<br></code></pre></td></tr></table></figure>
<h4 id="以–skip-grant-tables-选项启动服务，跳过权限表验证"><a href="#以–skip-grant-tables-选项启动服务，跳过权限表验证" class="headerlink" title="以–skip-grant-tables 选项启动服务，跳过权限表验证"></a>以–skip-grant-tables 选项启动服务，跳过权限表验证</h4><ol>
<li>方法一：指定运行选项，只在本次启动生效<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash">./bin/mysqld_safe --skip-grant-tables --user=root &amp;<br><span class="hljs-comment"># 如果本机没有mysqld_safe服务，运行mysqld效果相同</span><br></code></pre></td></tr></table></figure></li>
<li>方法二： 修改配置文件，使用service、systemctl启动均生效<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs bash"><span class="hljs-comment"># 修改配置文件my.cnf，添加 skip-grant-tables</span><br>my.cnf可能存在多个，请使用  sudo mysql --<span class="hljs-built_in">help</span> | grep my.cnf   或   mysql --<span class="hljs-built_in">help</span> | grep <span class="hljs-string">&#x27;Default options&#x27;</span> -A 1 确认加载顺序<br></code></pre></td></tr></table></figure></li>
</ol>
<h4 id="修改"><a href="#修改" class="headerlink" title="修改"></a>修改</h4><figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><code class="hljs bash"><br><span class="hljs-comment">#root账号登录mysql，此时不需要提供密码</span><br>mysql -uroot<br><br><span class="hljs-comment">#切换到mysql数据库，登录账号与权限在此数据库中</span><br>use mysql;<br><br><span class="hljs-comment">#查看mysql版本</span><br>select version();<br><br><span class="hljs-comment">#查看当前账户信息，根据mysql版本执行</span><br><span class="hljs-comment">#5.7+版本密码为authentication_string（生效），password；</span><br><span class="hljs-comment">#5.7-版本密码为password </span><br><span class="hljs-comment">#user=用户名，host=登录IP，即允许该账户登录的IP地址，每个IP一条user表记录，%表示任意IP</span><br>select user,host,authentication_string,password from user <span class="hljs-built_in">where</span> user=<span class="hljs-string">&#x27;root&#x27;</span>;<br><br><span class="hljs-comment">#5.7+设置密码</span><br>update user <span class="hljs-built_in">set</span> authentication_string=password(<span class="hljs-string">&#x27;password&#x27;</span>) <span class="hljs-built_in">where</span> user=<span class="hljs-string">&#x27;root&#x27;</span>;<br><br><span class="hljs-comment">#5.7-设置密码</span><br>update mysql.user <span class="hljs-built_in">set</span> password=password(<span class="hljs-string">&#x27;password&#x27;</span>) <span class="hljs-built_in">where</span> user=<span class="hljs-string">&#x27;root&#x27;</span>;<br><br><span class="hljs-comment">#5.7+支持2个密码字段，直接设置2个，生效为authentication_string</span><br>update user <span class="hljs-built_in">set</span> authentication_string=password(<span class="hljs-string">&#x27;password&#x27;</span>),password=password(<span class="hljs-string">&#x27;password&#x27;</span>) <span class="hljs-built_in">where</span> user=<span class="hljs-string">&#x27;root&#x27;</span> ;<br><br><span class="hljs-comment">#刷新权限表</span><br>flush privileges;<br><br><span class="hljs-comment">#退出mysql连接</span><br>quit;<br><br><span class="hljs-comment">#重启mysql服务</span><br>service mysqld restart<br><br></code></pre></td></tr></table></figure>

<h3 id="场景二：增加账号与授权"><a href="#场景二：增加账号与授权" class="headerlink" title="场景二：增加账号与授权"></a>场景二：增加账号与授权</h3><p>以上–skip-grant-tables模式不验证权限，同时无法增加账号授权，所以增加账号的登录IP，需要以正常模式启动登录</p>
<figure class="highlight bash"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br></pre></td><td class="code"><pre><code class="hljs bash"><br><span class="hljs-comment">#密码登录重启后的mysql服务</span><br>mysql -u root -p<br> <br><span class="hljs-comment">#切换mysql数据库，账号和权限在此数据库</span><br>use mysql;<br> <br><span class="hljs-comment">#增加账号授权</span><br>grant all privileges on *.* to <span class="hljs-string">&quot;root&quot;</span>@<span class="hljs-string">&quot;ip&quot;</span> identified by <span class="hljs-string">&quot;password&quot;</span> with grant option;<br> <br><span class="hljs-comment">#刷新权限表</span><br>flush privileges;<br> <br><span class="hljs-comment">#退出mysql连接</span><br>quit；<br> <br><span class="hljs-comment">#无需重启服务</span><br><br></code></pre></td></tr></table></figure>

<h3 id="场景三：修改登录密码"><a href="#场景三：修改登录密码" class="headerlink" title="场景三：修改登录密码"></a>场景三：修改登录密码</h3><h4 id="更新mysql-user表，需要登录MySQL执行，需要刷新权限列表生效"><a href="#更新mysql-user表，需要登录MySQL执行，需要刷新权限列表生效" class="headerlink" title="更新mysql.user表，需要登录MySQL执行，需要刷新权限列表生效"></a>更新mysql.user表，需要登录MySQL执行，需要刷新权限列表生效</h4><figure class="highlight routeros"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs routeros">mysql&gt; use mysql; #5.7前后版本密码字段不一致，且<span class="hljs-built_in"> user </span>表同时存在2个字段<br><span class="hljs-comment"># mysql5.7之前</span><br>mysql&gt; update<span class="hljs-built_in"> user </span><span class="hljs-built_in">set</span> <span class="hljs-attribute">password</span>=password(&#x27;123456&#x27;) where <span class="hljs-attribute">user</span>=<span class="hljs-string">&#x27;root&#x27;</span> <span class="hljs-keyword">and</span> <span class="hljs-attribute">host</span>=<span class="hljs-string">&#x27;localhost&#x27;</span>;<br><span class="hljs-comment"># mysql5.7之后</span><br>mysql&gt; update<span class="hljs-built_in"> user </span><span class="hljs-built_in">set</span> <span class="hljs-attribute">authentication_string</span>=password(&#x27;123456&#x27;) where <span class="hljs-attribute">user</span>=<span class="hljs-string">&#x27;root&#x27;</span> <span class="hljs-keyword">and</span> <span class="hljs-attribute">host</span>=<span class="hljs-string">&#x27;localhost&#x27;</span>;<br>mysql&gt; flush privileges; #刷新权限列表<br></code></pre></td></tr></table></figure>
<h4 id="用set-password命令，需要登录MySQL执行，自动刷新权限列表"><a href="#用set-password命令，需要登录MySQL执行，自动刷新权限列表" class="headerlink" title="用set password命令，需要登录MySQL执行，自动刷新权限列表"></a>用set password命令，需要登录MySQL执行，自动刷新权限列表</h4><figure class="highlight pgsql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs pgsql">语法：<span class="hljs-keyword">set</span> <span class="hljs-keyword">password</span> <span class="hljs-keyword">for</span> <span class="hljs-string">&#x27;用户名&#x27;</span>@<span class="hljs-string">&#x27;域&#x27;</span>=<span class="hljs-keyword">password</span>(‘密码’)<br>mysql&gt; <span class="hljs-keyword">set</span> <span class="hljs-keyword">password</span> <span class="hljs-keyword">for</span> <span class="hljs-string">&#x27;root&#x27;</span>@<span class="hljs-string">&#x27;localhost&#x27;</span>=<span class="hljs-keyword">password</span>(<span class="hljs-string">&#x27;123456&#x27;</span>);<br></code></pre></td></tr></table></figure>

<h4 id="alter-user命令，需要登录MySQL执行，自动刷新权限列表"><a href="#alter-user命令，需要登录MySQL执行，自动刷新权限列表" class="headerlink" title="alter user命令，需要登录MySQL执行，自动刷新权限列表"></a>alter user命令，需要登录MySQL执行，自动刷新权限列表</h4><figure class="highlight pgsql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br></pre></td><td class="code"><pre><code class="hljs pgsql">语法：<span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">USER</span> <span class="hljs-string">&#x27;用户名&#x27;</span>@<span class="hljs-string">&#x27;域&#x27;</span> IDENTIFIED <span class="hljs-keyword">BY</span> <span class="hljs-string">&#x27;xxxx&#x27;</span>; <br>#初始化时root账号只有localhost<br>mysql&gt; <span class="hljs-keyword">ALTER</span> <span class="hljs-keyword">USER</span> <span class="hljs-string">&#x27;root&#x27;</span>@<span class="hljs-string">&#x27;localhost&#x27;</span> IDENTIFIED <span class="hljs-keyword">BY</span> <span class="hljs-string">&#x27;123456&#x27;</span>;<br></code></pre></td></tr></table></figure>

<h4 id="grant命令，需要登录MySQL执行，自动刷新权限列表"><a href="#grant命令，需要登录MySQL执行，自动刷新权限列表" class="headerlink" title="grant命令，需要登录MySQL执行，自动刷新权限列表"></a>grant命令，需要登录MySQL执行，自动刷新权限列表</h4><figure class="highlight pgsql"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br></pre></td><td class="code"><pre><code class="hljs pgsql">语法：<span class="hljs-keyword">GRANT</span> 权限列表（逗号分隔） <span class="hljs-keyword">ON</span> 数据库.数据表 <span class="hljs-keyword">TO</span> <span class="hljs-string">&#x27;用户&#x27;</span>@<span class="hljs-string">&#x27;域&#x27;</span> IDENTIFIED <span class="hljs-keyword">BY</span> <span class="hljs-string">&#x27;密码&#x27;</span>;<br><span class="hljs-meta">#grant语句自动创建用户以及设置密码</span><br>#权限支持 <span class="hljs-keyword">create</span>、<span class="hljs-keyword">update</span>、<span class="hljs-keyword">select</span>、lete、<span class="hljs-keyword">drop</span>、<span class="hljs-keyword">execute</span>等，也可以指定 <span class="hljs-keyword">all</span> <span class="hljs-keyword">privileges</span> 授权所有权限<br><span class="hljs-meta">#grant语句最后可以指定 WITH GRANT OPTION 指定用户可以将权限传递授权给其他用户。</span><br>#数据库与数据表支持 * 指定全部，如 testdb.* 或 *.*，其他情况只能一条授权一个数据表<br>mysql&gt; <span class="hljs-keyword">GRANT</span> <span class="hljs-keyword">ALL</span> <span class="hljs-keyword">PRIVILEGES</span> <span class="hljs-keyword">ON</span> *.* <span class="hljs-keyword">TO</span> <span class="hljs-string">&#x27;root&#x27;</span>@<span class="hljs-string">&#x27;192.168.11.31&#x27;</span> IDENTIFIED <span class="hljs-keyword">BY</span> <span class="hljs-string">&#x27;Mysql.pass.123&#x27;</span> <span class="hljs-keyword">WITH</span> <span class="hljs-keyword">GRANT</span> <span class="hljs-keyword">OPTION</span>;<br></code></pre></td></tr></table></figure>

<h4 id="mysqladmin，无需登录MySQL执行，自动刷新权限列表"><a href="#mysqladmin，无需登录MySQL执行，自动刷新权限列表" class="headerlink" title="mysqladmin，无需登录MySQL执行，自动刷新权限列表"></a>mysqladmin，无需登录MySQL执行，自动刷新权限列表</h4><figure class="highlight vbnet"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br></pre></td><td class="code"><pre><code class="hljs vbnet">语法：mysqladmin -u用户名 -p旧的密码 password 新密码<br>#该方式为明文传输密码，不安全<br>[root@localhost ~]# mysqladmin -uroot -p123456 password <span class="hljs-number">1234</span>abcd<br><span class="hljs-symbol">mysqladmin:</span> [Warning] <span class="hljs-keyword">Using</span> a password <span class="hljs-keyword">on</span> the command line <span class="hljs-keyword">interface</span> can be insecure.<br><span class="hljs-built_in">New</span> password: <br>Confirm <span class="hljs-built_in">new</span> password: <br><span class="hljs-symbol">Warning:</span> Since password will be sent <span class="hljs-keyword">to</span> server <span class="hljs-keyword">in</span> plain <span class="hljs-keyword">text</span>, use ssl connecti<br></code></pre></td></tr></table></figure>
                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
    <div class="post-meta mr-3 d-flex align-items-center">
      <i class="iconfont icon-category"></i>
      

<span class="category-chains">
  
  
    
      <span class="category-chain">
        
  <a href="/categories/mysql/" class="category-chain-item">mysql</a>
  
  

      </span>
    
  
</span>

    </div>
  
  
    <div class="post-meta">
      <i class="iconfont icon-tags"></i>
      
        <a href="/tags/mysql/">#mysql</a>
      
    </div>
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>Mysql忘记root密码解决方案</div>
      <div>https://sweetshance.github.io/2024/04/23/mysql/Mysql忘记root密码解决方案/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>ShanCe</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2024年4月23日</div>
        </div>
      
      
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2024/05/09/uwsgi/supervisorctl-django-uwsgi%E9%83%A8%E7%BD%B2/" title="supervisorctl+django+uwsgi部署">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">supervisorctl+django+uwsgi部署</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                      <a href="/2024/04/19/python%E7%9B%B8%E5%85%B3%E7%9F%A5%E8%AF%86%E7%82%B9/vscode+django/" title="Vscode + Python + Django">
                        <span class="hidden-mobile">Vscode + Python + Django</span>
                        <span class="visible-mobile">下一篇</span>
                        <i class="iconfont icon-arrowright"></i>
                      </a>
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header">
    <i class="iconfont icon-list"></i>
    <span>目录</span>
  </p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="http://82.157.172.231/" target="_blank" rel="nofollow noopener"><span>无聊</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>ShanCe</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>





<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
